package org.xmh.demo;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorld extends ActionSupport{

	private static final long serialVersionUID = 4946765739656374889L;

	private String message;
	
	@Override
	public String execute() throws Exception {
		this.setMessage("invoking execute method,time:"+DateFormat.getDateInstance().format(new Date()));
		return SUCCESS;
	}

	public void testJson(){
		HttpServletResponse res = ServletActionContext.getResponse();
		try {
			PrintWriter out = res.getWriter();
			out.write("123");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public String test(){
		System.out.println("HelloWorld test method");
		return SUCCESS;
	}
	
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}
